#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    readSettings();
}

Widget::~Widget()
{
    writeSettings();
    delete ui;
}

void Widget::on_pushButton_clicked()
{
    close();
}

void Widget::readSettings()
{
    // read
    QSettings setting("Industria", "Tarifador");
    setting.beginGroup("PosAndSize");
    QPoint  pos     = setting.value("position", QPoint(50, 50)).toPoint();
    QSize   size    = setting.value("tamanho", QSize(500, 300)).toSize();
    setting.endGroup();
    resize(size);
    move(pos);
}

void Widget::writeSettings()
{
    // write
    QSettings setting("Industria", "Tarifador");
    setting.beginGroup("PosAndSize");
    setting.setValue("position", pos());
    setting.setValue("tamanho", size());
    setting.endGroup();
}
